package com.linln.admin.good.repository;

import com.linln.admin.good.domain.Category;
import com.linln.common.constant.StatusConst;
import com.linln.modules.system.repository.BaseRepository;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author 小懒虫
 * <p>@Date 2021/04/03
 */
public interface CategoryRepository extends BaseRepository<Category, Long> {
    /**
     * <p>根据父级id查询最大序号
     * <p>@date 2021/4/6 22:46
     *
     * @param pid 父级id
     * @author sunkaichun
     * @return java.lang.Integer
     **/
    @Query(value = "select max(sort) from Category c where c.pid = ?1 and c.status <> " + StatusConst.DELETE)
    public Integer findSortMax(Long pid);

    public List<Category> findListByPidAndIdNot(Sort sort, long pid, long notId);
}